#ifndef HOOK_H
#define HOOK_H

#include <iostream>
#include <vector>
#include <map>

#include "httplib.h"

namespace nmsp
{
    struct Cont;
    typedef std::function<void(Cont *, const httplib::Request &, httplib::Response &)> PluginCallback;

    enum HttpHookID
    {
        HTTP_READ_REQUEST_HDR_HOOK,
        HTTP_OS_DNS_HOOK,
        HTTP_SEND_REQUEST_HDR_HOOK,
        HTTP_READ_CACHE_HDR_HOOK,
        HTTP_READ_RESPONSE_HDR_HOOK,
        HTTP_SEND_RESPONSE_HDR_HOOK,
        HTTP_REQUEST_TRANSFORM_HOOK,
        HTTP_RESPONSE_TRANSFORM_HOOK,
        HTTP_RESPONSE_CLIENT_HOOK,
        HTTP_TXN_START_HOOK,
        HTTP_TXN_CLOSE_HOOK,
        HTTP_SSN_CLOSE_HOOK,
    }; // 这里只使用 HTTP_READ_REQUEST_HDR_HOOK 就行,

    typedef struct Cont
    {
    private:
        std::string pattern;
        PluginCallback pluginCallback;
        httplib::Server *server;
        void *data;

    public:
        Cont(const std::string &pattern, PluginCallback pluginCallback, void *data);
        ~Cont();
        const std::string GetPattern() const { return pattern; }
        void SetServer(httplib::Server *server) { this->server = server; }
        void *GetData() { return data; }

        //  using Handler = std::function<void(const Request &, Response &)>;
        void RegisterGet(const httplib::Request &req, httplib::Response &resp);

    } Cont_t, *Contp;

}
#endif